<div class="layui-body-header">
	<h2>会议列表</h2>
</div>

<div class="layui-card-body">
	<div class="layui-fluid">
		<div class="layui-card">
          <div class="layui-card-header">
            <!-- <span>所有会员列表</span> -->
            <a href="#/layui/addMeet" class="layui-btn layui-btn-sm">
              <i class="layui-icon">&#xe654;</i>
              <span>添加</span>
            </a>
            <!--<a href="#/layui/addMeet" class="layui-btn layui-btn-xs layui-btn-primary">
              <i class="layui-icon">&#xe642;</i>
              <span>编辑</span>
            </a>-->
            <button type="button" class="layui-btn layui-btn-sm layui-btn-danger batchDel">
              <i class="layui-icon">&#xe640;</i>
              <span>批量删除</span>
            </button>
            <!--<button type="button" class="layui-btn layui-btn-sm layui-btn-primary check">
              <i class="layui-icon">&#xe63c;</i>
              <span>考勤</span>
            </button>-->
            <a href="javascript:;" class="layui-btn layui-btn-sm layui-btn-primary" id="search_hash">
              <i class="layui-icon">&#xe615;</i>
            </a>
          </div>
          <div class="layui-card-body">
            <table id="test" lay-filter="test" ></table>
            <script type="text/html" id="bartest">
            	<a class="layui-btn layui-btn-xs" lay-event="xiangqing">考勤</a>
              <a class="layui-btn layui-btn-xs" lay-event="detail">编辑</a>
              <!--<a class="layui-btn layui-btn-xs" lay-event="watchMem">统计</a>-->
              <!-- <a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a> -->
            </script>
	  		</div>
	  	</div>
	  </div>
	</div>
      

<script type="text/html" id="search_tpl_hash">
  <form class="layui-form" action="">
    <div class="layui-form-item">
      <label class="layui-form-label">会议名称</label>
      <div class="layui-input-block">
        <input type="text" name="meetName" id="meetName" placeholder="" autocomplete="off" class="layui-input">
      </div>
    </div>
    <!--<div class="layui-form-item">
      <label class="layui-form-label">会议状态</label>
      <div class="layui-input-block">
        <select name="state">
          <option value="0">全部</option>
          <option value="1">进行中</option>
          <option value="2">已结束</option>
        </select>
      </div>
    </div>-->
    <div class="layui-form-item">
      <div class="layui-input-block">
        <button class="layui-btn" lay-submit lay-filter="formtest"><i class="layui-icon">&#xe615;</i> 搜索</button>
        <button type="reset" class="layui-btn layui-btn-primary">重置</button>
      </div>
    </div>
  </form>
</script>

<script>
//	let check = document.querySelector(".check")
	let checkedArr = [];
	let objArr = [];	
	let batchDel = document.querySelector(".batchDel");
//	let testOne = document.querySelector(".testOne");
	
  layui.use(['jquery', 'mockjs', 'table', 'sidebar', 'form'], function () {
    var $ = layui.jquery,
      layer = layui.layer,
      table = layui.table,
      
      sidebar = layui.sidebar,
      form = layui.form;
    // 注入mock
    layui.mockjs.inject({
      'POST /demo/table/user': {
        code: 0,
        msg: "xxx",
        count: 1000,
        'data|20': [{
          'id|+1': 1,
          username: '@name',
          sex: '@boolean',
          city: '@city',
          sign: '@csentence',
          experience: '@integer',
          score: '@integer',
          classify: '@word',
          wealth: '@integer',
          auth: '@boolean'
        }]
      }
    });
    //第一个实例
    table.render({
      method: 'post',
      // size: 'sm',
      limit: 10, 
      limits: [10,20,30],
      elem: '#test',
      id:'test',
      height: 'full-235',
      parseData: function(res){
      	return {
      		'code':0,
      		'count':res.TotalCount,
      		"data":res._Data
      	};
      },
      contentType: 'application/json',
      where: {
			  "Name": "",
			  "MeetingStatus": 0,
      },
	     request: {
			    pageName: 'CurrentPage' //页码的参数名称，默认：page
			    ,limitName: 'PageSize' //每页数据量的参数名，默认：limit
			  },
     	url: 'https://xnsmb.xnsoft.net.cn/api/Filtrate_Xn_Meeting', //数据接口
      page: true, //开启分页
      cols: [
        [ //表头
          {
//          field: 'id',
//          title: 'ID',
//          width: 70,
            sort: true,
            type: 'checkbox',
            align: 'center',
            fixed: 'left'
          }, 
//        {
//          field: 'Guid',
//          title: '会议ID',
//          align: 'center',
////          width: 135
//        },
          {
            field: 'Name',
            title: '会议名称',
            align: 'center',
//          width: 135
          }, {
            field: 'Address',
            title: '举办地点',
            align: 'center',
//          width: 135
          }, {
            field: 'StartTime',
            title: '开始时间',
            align: 'center',
//          width: 135
          }, {
            field: 'SignInCount',
            title: '签到人数',
            align: 'center',
//          width: 135,
            sort: true
          }, {
            field: 'BeLateCount',
            title: '迟到人数',
            align: 'center',
//          width: 135,
            sort: true
          }, 
//        {
//          field: '',
//          title: '累计报名',
//          align: 'center',
//        }, 
//        {
//          field: 'MeetingStatus',
//          title: '会议状态',
//          align: 'center',
//          templet:function(d){
//          	if(d.MeetingStatus==0){
//          		return '<span>全部</span>'
//          	}else if(d.MeetingStatus==1){
//          		return '<span>进行中</span>'
//          	}else if(d.MeetingStatus==2){
//          		return '<span>已结束</span>'
//          	}
//          }
////          width: 135
//        }, 
          {
            fixed: 'right',
//          width: 180,
            title: '操作',
            align: 'center',
            toolbar: '#bartest'
          }
        ]
      ]
    });
    
    var checkStatus = table.checkStatus('test');
    
//  testOne.addEventListener("click",function(){
//  	console.log(checkStatus.data)
//  })
    
    
    table.on('checkbox(test)', function(obj){
			var checkStatus = table.checkStatus('test');
			let temp = [];
			let tempObj = [];
			checkStatus.data.forEach((el,index)=>{
				temp.push(el.Guid);
			})
			checkedArr = temp;
			console.log(temp)
//			console.log("checkedArr",checkedArr);
//			console.log("obj",obj)
//			console.log("checkStatus.data",checkStatus)
//			if(obj.type=="one"){
//				if(obj.checked){
//					objArr.push(obj)
////					checkedArr.push(obj.data.Guid)
//					
//				}else if(!obj.checked){
//					objArr.splice(objArr.indexOf(obj.data),1)
////					checkedArr.splice(checkedArr.indexOf(obj.data.Guid),1)
////					console.log(objArr)
//				}
//			}
		
		});
		
		table.on('tool(test)',function(obj){
    	toolHandel("#/layui/addMeet?id=","Admin_Xn_Meeting/",obj,"#/layui/kaoqinList?id=");
    })

    $('#search_hash').on('click', function () {
      var that = this;
      // console.log($('#search_tpl_hash').html());
      sidebar.render({
        elem: that,
        content: $('#search_tpl_hash').html(),
        title: '搜索',
        shade: true,
        width: '500px', //可以设置百分比和px
        done: function () {
          console.log('ccc');
          form.render();

          //监听提交
          form.on('submit(formtest)', function (data) {
            // layer.msg(JSON.stringify(data.field));
            table.reload('test', {
              where: {
              	"Name": $("#meetName").val(),
              }
            });
            return false;
          });
        }
      });
    });
    
//  批量删除
    batchDel.addEventListener("click",function(){
    	if(checkedArr.length!=0){
    		layer.confirm('确认删除？', function(index){
					layer.close(index);	
					console.log("checkedArr",checkedArr)
					DBHelper.Delete("Admin_Xn_Meeting",checkedArr,function(data){
				      	console.log(data)
				      },function(data){
				      	table.reload('test', {
								});
				      	console.log(data)
				      })
					
		    });
    	}else if(checkedArr.length==0){
			layer.alert("请选择至少一个选项")
		}
			
			
    })
    
  });
  
  
//	check.addEventListener("click",function(){
//		if(checkedArr.length>1){
//			layer.alert("请不要选择超过两个选项")
//		}else if(checkedArr.length==1){
//			console.log(checkedArr[0])
//			window.location.href = "#/layui/kaoqinList?id="+checkedArr[0];
//		}
//	})
</script>


<style scoped>
	.qxMaBtn{
		margin-bottom: 20px;
	}
		.qxMaInfo-table{
			font-size: 12px;
		}
		.qxMaInfo-table tr>th{
			text-align: center;
			font-size: 12px;
		}
		.qxMaInfo-table tr>td{
			text-align: center;
			font-size: 12px;
		}
      	.block{
      		display: block;
      	}
      	.qxMaTop-btn{
      		width: 100%;
      		text-align: center;
      	}
      	.qxMaInfo{
      		margin-top: 20px;
      		margin-bottom: 30px;
      	}
      	.qxMaTop-btn button{
      		display: inline-block;
      		width: 200px;
      		border-radius: 5px;
      	}
      	.title{
      		margin-left: 30px;
      		margin-top: 30px;
      	}
      	.save-warp{
      		width: 100%;
      		text-align: center;
      		margin-top: 20px;
      	}
      	.save-warp button{
      		display: inline-block;
      		width: 160px;
      	}
      	.qxMa-top{
      		display: flex;
      		justify-content: space-between;
      	}
      	.qxMa-table{
      		background-color: rgba(0,0,0,0);
      	}
      	
      	
      </style>





